package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmMaterialDto;
import com.heima.wemedia.service.WmMaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController {

    @Autowired
    private WmMaterialService wmMaterialService;


    @PostMapping("/upload_picture")
    public ResponseResult uploadPicture(MultipartFile multipartFile){
        return wmMaterialService.uploadPicture(multipartFile);
    }
    /*
     * @description: 图片列表展示
     * @author: 椎名真白
     * @date: 2022-06-14 14:32
     * @param: dto
     * @return: com.heima.model.common.dtos.ResponseResult
     **/
    @PostMapping("/list")
    public ResponseResult list(@RequestBody WmMaterialDto dto){
        return wmMaterialService.findList(dto);
    }

    /*
     * @description: 删除图片
     * @author: 椎名真白
     * @date: 2022-06-14 18:09
     * @return: com.heima.model.common.dtos.ResponseResult
     **/
    @GetMapping("/del_picture/{id}")
    public ResponseResult deleteImage(@PathVariable Integer id){
        return wmMaterialService.delete(id);
    }

    /*
     * @description: 取消收藏
     * @author: 椎名真白
     * @date: 2022-06-14 18:22
     * @return: com.heima.model.common.dtos.ResponseResult
     **/
    @GetMapping("cancel_collect/{id}")
    public ResponseResult cancel_collect(@PathVariable Integer id){
        return wmMaterialService.cancelCollection(id);
    }

    /*
     * @description: 取消收藏
     * @author: 椎名真白
     * @date: 2022-06-14 18:22
     * @return: com.heima.model.common.dtos.ResponseResult
     **/
    @GetMapping("collect/{id}")
    public ResponseResult collect(@PathVariable Integer id){
        return wmMaterialService.collection(id);
    }
}